//
//  ZCRaisePayMoneyCell.m
//  zctx
//
//  Created by apple on 16/1/23.
//  Copyright © 2016年 sanliang. All rights reserved.
//

#import "ZCRaisePayMoneyCell.h"

@implementation ZCRaisePayMoneyCell

- (void)awakeFromNib {
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier cellType:(ZCRaisePayMoneyCellType)type andRed:(BOOL)red{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.isRed = red;
        if (type == ZCRaisePayMoneyCellTypeRed) {
            [self addRedCell];
//            self.titleLable.textColor = [UIColor colorWithHexString:@"#000000"];
             [self RedView];
        } else if (type == ZCRaisePayMoneyCellTypeMoney) {
            [self addMoneyCell];
//            self.titleLable.textColor = [UIColor colorWithHexString:@"#525252"];
        } else if (type == ZCRaisePayMoneyCellTypeNoRed){
            [self addRedCell];
            [self noRedView];
        }
    }
    return self;
}

-(void)addRedCell{
    [self.contentView addSubview:self.titleLable];
    [self.titleLable makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.left).with.offset(19);
        make.centerY.equalTo(self.contentView.centerY).with.offset(0);
        make.width.mas_equalTo(150);
        make.height.mas_equalTo(21);
    }];
    
    [self.contentView addSubview:self.rightView];
    [self.rightView makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.right).with.offset(-19);
        make.centerY.equalTo(self.contentView.centerY).with.offset(0);
        make.width.mas_equalTo(13);
        make.height.mas_equalTo(13);
    }];
    
   
}

-(void)noRedView{
    [self.contentView addSubview:self.redLable];
    [self.redLable makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.rightView.right).with.offset(0);
        make.centerY.equalTo(self.contentView.centerY).with.offset(0);
        make.width.mas_equalTo(120);
        make.height.mas_equalTo(21);
    }];
    self.redLable.text = @"没有可用红包";
    self.redLable.font = [UIFont systemFontOfSize:13];
    self.redLable.textColor = [UIColor colorWithHexString:@"#8a8a8a"];
}

-(void)RedView{
    
    NSLog(@"sdf");
    [self.contentView addSubview:self.redView];
    [self.redView makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.rightView.left).with.offset(-6);
        make.centerY.equalTo(self.contentView.centerY).with.offset(0);
        make.width.mas_equalTo(70);
        make.height.mas_equalTo(20);
    }];
    
    [self.redView addSubview:self.ImgView];
    [self.ImgView makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.redView.left).with.offset(5);
        make.centerY.equalTo(self.redView.centerY).with.offset(0);
        make.width.mas_equalTo(17);
        make.height.mas_equalTo(17);
    }];
    
    [self.redView addSubview:self.redLable];
    [self.redLable makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.ImgView.right).with.offset(0);
        make.centerY.equalTo(self.redView.centerY).with.offset(0);
        make.right.equalTo(self.redView.right).with.offset(0);
        make.height.mas_equalTo(16);
    }];
    self.redLable.font = [UIFont systemFontOfSize:10];
    self.redLable.textColor = [UIColor whiteColor];

}

-(void)addMoneyCell{
    [self.contentView addSubview:self.titleLable];
    [self.titleLable makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.left).with.offset(19);
        make.centerY.equalTo(self.contentView.centerY).with.offset(0);
        make.width.mas_equalTo(150);
        make.height.mas_equalTo(21);
    }];
    
    [self.contentView addSubview:self.moneyLable];
    [self.moneyLable makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.right).with.offset(-19);
        make.centerY.equalTo(self.contentView.centerY).with.offset(0);
        make.width.mas_equalTo(120);
        make.height.mas_equalTo(21);
    }];
}

- (UILabel *)titleLable {
    if (!_titleLable) {
        _titleLable = [[UILabel alloc] init];
        [_titleLable setTextColor:[UIColor colorWithHexString:@"#000000"]];
        _titleLable.textAlignment = NSTextAlignmentLeft;
        _titleLable.font = [UIFont systemFontOfSize:15];
    }
    return _titleLable;
}
- (UILabel *)moneyLable {
    if (!_moneyLable) {
        _moneyLable = [[UILabel alloc] init];
        _moneyLable.textAlignment = NSTextAlignmentRight;
        _moneyLable.font = [UIFont systemFontOfSize:15];
        [_moneyLable setTextColor:[UIColor colorWithHexString:@"#ff4646"]];
    }
    return _moneyLable;
}


- (UILabel *)redLable {
    if (!_redLable) {
        _redLable = [[UILabel alloc] init];
        _redLable.textAlignment = NSTextAlignmentCenter;
        _redLable.font = [UIFont systemFontOfSize:15];
        [_redLable setTextColor:[UIColor colorWithHexString:@"#a3a3a3"]];
    }
    return _redLable;
}
-(UIView *)redView{
    if (!_redView) {
        _redView = [[UIView alloc]init];
        _redView.backgroundColor = [UIColor colorWithHexString:@"#ff5f3e"];
        _redView.layer.cornerRadius =4;
        
    }
    return _redView;
}

-(UIImageView *)ImgView{
    if (!_ImgView) {
        _ImgView = [[UIImageView alloc]init];
        _ImgView.image = [UIImage imageNamed:@"me_red_money"];
    }
    return _ImgView;
}

-(UIImageView *)rightView{
    if (!_rightView) {
        _rightView = [[UIImageView alloc]init];
        _rightView.image = [UIImage imageNamed:@"harm_right"];
    }
    return _rightView;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
